﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using PortalIntranet.DatabaseComponents.Administracao;
using PortalIntranet.DatabaseComponents.Comun;
using System.Data.Entity.ModelConfiguration;

namespace PortalIntranet.DatabaseComponents.WebParts
{
	[Serializable]
	[Table("WebParts")]
	public class WebPart : Entidade
	{
		public WebPart()
		{
		}

		[Required, MaxLength(50)]
		public string Nome { get; set; }

		public TipoWebPart TipoWebPart { get; set; }

		public LinhaPortlet Linha { get; set; }

		public int Coluna { get; set; }

		public int Ordem { get; set; }

		public CorWebPart Cor { get; set; }

		public bool PermitirMinimizar { get; set; }

		public bool ExibirCabecalho { get; set; }

		public bool ExibirBordas { get; set; }

		public int Altura { get; set; }

		#region WebPage
		public int WebPageId { get; set; }

		public virtual WebPage WebPage { get; set; }
		#endregion
	}

	internal class WebPartConfiguration : EntityTypeConfiguration<WebPart>
	{
		internal WebPartConfiguration()
		{
			this.HasRequired(b => b.WebPage)
				.WithMany(i => i.WebParts)
				.HasForeignKey(b => b.WebPageId);
		}
	}
}
